const path = require('path');
var HtmlWebpackPlugin = require('html-webpack-plugin');
const merge = require('webpack-merge')
const baseWebpackConfig = require('./base.js')
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
var webpack = require('webpack')
const TerserPlugin = require('terser-webpack-plugin');

module.exports = merge(baseWebpackConfig, {
  // devtool: 'eval-source-map',
  devtool: false,
  mode: 'production',
  output: {
    path: path.resolve(__dirname, "../../build/app"),
    filename: "bundle.js",
    publicPath: ""
  },
  optimization: {
    minimizer: [
      new TerserPlugin({
        sourceMap: false,
        parallel: true,
        extractComments:false,
        terserOptions:{
          keep_fnames: true,
        }
      }),
    ],
  },
  plugins: [
    // new OptimizeCSSPlugin({
    //   cssProcessorOptions: false
    //     ? { safe: true, map: { inline: false } }
    //     : { safe: true }
    // }),
    // new UglifyJsPlugin({
    //   uglifyOptions: {
    //     compress: {
    //       warnings: false
    //     }
    //   },
    //   // sourceMap: false,
    //   parallel: true
    // }),
      new webpack.HashedModuleIdsPlugin(),
      // new UglifyJsPlugin({
      //   uglifyOptions: {
      //     compress: {
      //       warnings: false,
      //       drop_debugger: true,
      //       drop_console: true
      //     }
      //   },
      //   sourceMap: false,
      //   parallel: true
      // }),
    // new CopyWebpackPlugin([
    //   {
    //     from: path.resolve(__dirname, '../static'),
    //     to: '../app-dist/static',
    //     ignore: ['.*']
    //   }
    // ])
  ]
})